<?php
/**
 * Created by PhpStorm.
 * User: warcello
 * Date: 2016/10/13
 * Time: 下午3:34
 */
class indexAppModule extends Module
{
    /*
    * 在构造函数中装载所依赖的类或其他文件
   */
    function __construct()
    {
        $this->includePhp('indexApp', 'indexApp');
    }

    /*
    * 调用插件资源
   */
    public function call($user, $method, $param)
    {
        switch ($method) {
            case "index":
                indexApp::index($param);
                break;
            case "getProductList":
                $start = $param->start;
                $limit = $param->limit;
                indexApp::getProductList($start ,$limit);
                break;
            case "getUploadImage":
                indexApp::getUploadImage($param);
                break;
            case "editProduct":
                $id = $param->id;
                indexApp::editProduct($id);
                break;
            case "addProduct":
                $id = $param->id;
                $vId = $param->vId;
                $description = $param->description;
                $name = $param->name;
                $inventoryCount = $param->inventoryCount;
                $fixedPrice = $param->fixedPrice;
                $picUrl = $param->picUrl;
                $picUrl1 = $param->picUrl1;
                $inventory = 1;
                $isRemoved = $param->isRemoved;
                indexApp::addProduct($id,$name,$vId,$description,$inventoryCount,$inventory,$inventoryCount,$isRemoved,$fixedPrice,$picUrl,$picUrl1);
                break;
            case "deleteProduct":
                $id = $param->id;
                indexApp::deleteProduct($id);
                break;
            case "getIdentity":
                indexApp::getIdentity();
                break;
            case "activeAgent":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::activeAgent($id);
                break;
            case "channelVendor":
                $id = $param->id;
                $start = $param->start;
                $limit = $param->limit;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::channelVendor($id,$start,$limit);
                break;
			case "getVendorStatistics":
				$id = $param->id;
				if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
				$search = $param->search;
				$limit = $param->limit;
				$start = $param->start;
				$order = $param->order;
				indexApp::getVendorStatistics($id,$search,$start,$limit,$order);
				break;
            case "userVisit":
                $start = $param->start;
                $limit = $param->limit;
                indexApp::userVisit($start,$limit);
                break;
            case "channelQrcode":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::channelQrcode($id);
                break;
            case "getConfig":
                indexApp::getVendorConfig();
                break;
            case "vendorCodeActivate":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::vendorCodeActivate($id);
                break;
            case "getVendorAccount":
                $id = $param->id;
                $start = $param->start;
                $limit = $param->limit;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::getVendorAccount($id,$start,$limit);
                break;
            case "getStoreIndex":
                $id = $param->id;
				$codeId=$param->codeId;
               
                indexApp::getStoreIndex($id,$codeId);
                break;
            case "getAllShow":
                $id = $param->id;
                $start = $param->start;
                $limit = $param->limit;
                $isAll = $param->isAll;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::getAllShow($id,$start,$limit,$isAll);
                break;
            case "delShowGroup":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::delShowGroup($id);
                break;
            case "setShowGroup":
                $name = $param->name;
                $list = $param->list;
                $id = $param->id;
                if(!$name||!$list){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::setShowGroup($name,$list,$id);
                break;
            case "saveStore":
                $name = $param->name;
                $phone = $param->phone;
                $tel = $param->tel;
                $province = $param->province;
                $city = $param->city;
                $country = $param->country;
                $address = $param->address;
                $longitude = $param->longitude;
                $latitude = $param->latitude;
                $id = $param->id;
                indexApp::saveStore($name,$phone,$tel,$province,$city,$country,$address,$longitude,$latitude,$id);
                break;
            case "getCouponList":
                $id = $param->id;
                $start = $param->start;
                $limit = $param->limit;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::getCouponList($id,$start,$limit);
                break;
            case "writeOffCoupon":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::writeOffCoupon($id);
                break;
            case "vendorVisitStatistics":
                $id = $param->id;
                $start = $param->start;
                $limit = $param->limit;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::vendorVisitStatistics($id,$start,$limit);
                break;
            case "saveCoupon":
                $vid= $param->vid;
                $name= $param->name;
                $recommend= $param->recommend;
                $startTime= $param->startTime;
                $endTime= $param->endTime;
                $copiesNum= $param->copiesNum;
                $id= $param->id;
                indexApp::saveCoupon($vid,$name,$recommend,$startTime,$endTime,$copiesNum,$id);
                break;
            case "joinCoupon":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
				$fromUserId = $param->fromUserId;
                indexApp::joinCoupon($id,$fromUserId);
                break;
            case "getCouponDetail":
                $id = $param->id;
                indexApp::getCouponDetail($id);
                break;
            case "visitCoupon":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                $fromUserId = $param->fromUserId;
                indexApp::visitCoupon($id,$fromUserId);
                break;
            case "useCoupon":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::useCoupon($id);
                break;
            case "delCoupon":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::delCoupon($id);
                break;
            case 'saveStorePic':
                $id = $param->id;
                $picUrl = $param->picUrl;
                if(!$id||!$picUrl){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::saveStorePic($id,$picUrl);
                break;
            case "couponUserList":
                $id = $param->id;
                $type = $param->type;
                $start = $param->start;
                $limit = $param->limit;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::couponUserList($id,$type,$start,$limit);
                break;
            case "getUserCouponInfo":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::getUserCouponInfo($id);
                break;
            case "getStoreInfo":
                $id = $param->id;
                if(!$id){
                    Output::instance()->resultCode(code_lackof_param);
                    return;
                }
                indexApp::getStoreInfo($id);
                break;
            case "getCity":
                $id = $param->id;
                $province = $param->province;
                $city = $param->city;
                indexApp::getCity($id,$province,$city);
                break;
        }
    }

}
$module = new indexAppModule();
Module::addModule($module);
